Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Lazy*<T> types in rustc_metadata not care about lifetimes until decode #97376

Merged
merged 1 commit into from
May 25, 2022

Conversation

compiler-errors
Copy link
Member

This allows us to remove the 'tcx lifetime from CrateRoot. This is necessary because of #97287, which makes the 'tcx lifetime on Ty invariant instead of covariant, so this hack no longer holds under that PR.

Introduces a trait called ParameterizedOverTcx which has a generic associated type that allows a type to be parameterized over that lifetime. This means we can decode, for example, Lazy<Ty<'static>> into any Ty<'tcx> depending on the TyCtxt<'tcx> we pass into the decode function.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 24, 2022
@rust-highfive
Copy link
Collaborator

r? @wesleywiser

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 24, 2022
self, Const, FnSig, GeneratorDiagnosticData, GenericPredicates, Predicate, TraitRef, Ty,
};

pub trait ParameterizedOverTcx: 'static {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question: Does this really need to be : 'static? These impls also could be impl<'a> ParameterizedOverTcx for Thing<'a> { type Value<'tcx> = Thing<'tcx>; }, right? Because This is just encoding a higher-kinded lifetime -> type.

Copy link
Member Author

@compiler-errors compiler-errors May 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there's no good reason why we need Self: 'static. That is, it's not there for correctness or anything, necessarily.

I treat it more like a mnemonic, where the lifetime error you'd get is there to discourage you from constructing Lazy<Something<'not_static>>, since there is no guarantee that the 'not_static lifetime is not related to what you get out of lazy.decode(meta).

@jackh726
Copy link
Member

One question, but r=me

@compiler-errors
Copy link
Member Author

I guess this could use a perf run too.

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 25, 2022
@bors
Copy link
Contributor

bors commented May 25, 2022

⌛ Trying commit d1a9a95 with merge b4f81f3aa398c1b6b271826fc9a5c488fadc565f...

@bors
Copy link
Contributor

bors commented May 25, 2022

☀️ Try build successful - checks-actions
Build commit: b4f81f3aa398c1b6b271826fc9a5c488fadc565f (b4f81f3aa398c1b6b271826fc9a5c488fadc565f)

@rust-timer
Copy link
Collaborator

Queued b4f81f3aa398c1b6b271826fc9a5c488fadc565f with parent 76761db, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b4f81f3aa398c1b6b271826fc9a5c488fadc565f): comparison url.

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results
  • Primary benchmarks: mixed results
  • Secondary benchmarks: no relevant changes found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 1 0 1 0 2
mean2 2.9% N/A -1.7% N/A 0.6%
max 2.9% N/A -1.7% N/A 2.9%

Cycles

Results
  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 🎉 relevant improvements found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 0 0 6 0
mean2 N/A N/A N/A -11.8% N/A
max N/A N/A N/A -12.9% N/A

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf -perf-regression

Footnotes

  1. number of relevant changes 2

  2. the arithmetic mean of the percent change 2

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 25, 2022
@compiler-errors
Copy link
Member Author

@bors r=jackh726

@bors
Copy link
Contributor

bors commented May 25, 2022

📌 Commit d1a9a95 has been approved by jackh726

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 25, 2022
@bors
Copy link
Contributor

bors commented May 25, 2022

⌛ Testing commit d1a9a95 with merge 9fadabc...

@bors
Copy link
Contributor

bors commented May 25, 2022

☀️ Test successful - checks-actions
Approved by: jackh726
Pushing 9fadabc to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 25, 2022
@bors bors merged commit 9fadabc into rust-lang:master May 25, 2022
@rustbot rustbot added this to the 1.63.0 milestone May 25, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9fadabc): comparison url.

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results
  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 😿 relevant regressions found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 3 0 0 0
mean2 N/A 2.4% N/A N/A N/A
max N/A 2.9% N/A N/A N/A

Cycles

Results
  • Primary benchmarks: 😿 relevant regression found
  • Secondary benchmarks: 😿 relevant regressions found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 1 7 0 1 1
mean2 2.0% 3.1% N/A -2.2% 2.0%
max 2.0% 4.7% N/A -2.2% 2.0%

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Footnotes

  1. number of relevant changes 2

  2. the arithmetic mean of the percent change 2

@Noratrieb Noratrieb mentioned this pull request Dec 22, 2022
Noratrieb added a commit to Noratrieb/rust that referenced this pull request Dec 23, 2022
…nkov

A few metadata nits

Found while reading through the code. The `NOTE` is outdated now after rust-lang#97376.
Noratrieb added a commit to Noratrieb/rust that referenced this pull request Dec 23, 2022
…nkov

A few metadata nits

Found while reading through the code. The `NOTE` is outdated now after rust-lang#97376.
@compiler-errors compiler-errors deleted the lazy-polymorphic branch August 11, 2023 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants